package MyApp;
import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.example.myapplication.R;

import java.util.Arrays;
import java.util.Random;

public class Food extends AppCompatActivity {

    private RadioGroup mealGroup;
    private TextView recommendationTextView;
    private String[] breakfast = {
            "粥", "包子", "鸡蛋", "煎饼", "面包", "麦片", "酸奶", "水果沙拉", "全麦吐司", "豆浆", "水煮蛋", "坚果", "干果", "瘦肉", "低脂牛奶", "玉米片", "奶酪", "燕麦", "蔬菜沙拉", "水果酸奶", "蜂蜜", "咖啡", "茶", "果汁", "三明治", "培根", "香肠", "土豆泥", "热狗", "薄煎饼", "华夫饼", "肉松", "豆腐脑"
    };
    private String[] lunch = {
            "北京烤鸭", "四川火锅", "广东烧腊", "上海红烧肉", "湖南剁椒鱼头", "新疆大盘鸡", "云南过桥米线", "浙江东坡肉", "山东鲁菜", "陕西油泼面", "江西瓦灰鸡", "东北地三鲜", "日本寿司和刺身", "韩国泡菜和石锅拌饭", "泰国绿咖喱鸡", "越南春卷", "印度咖喱", "新加坡海南鸡饭", "马来西亚椰浆饭", "意大利千层面", "法国鹅肝酱", "西班牙海鲜饭", "墨西哥塔可", "希腊沙拉", "美国烤肋排", "四川麻辣烫", "重庆小面", "陕西凉皮", "河南烩面", "天津煎饼果子", "武汉热干面", "南京盐水鸭", "广西螺蛳粉", "素炒面", "素炖菜", "素寿司", "豆腐创意菜", "蔬菜拼盘","鸡公煲","学城香厨","肉蟹煲","海底捞"
    };
    private String[] dinner = {
            "清蒸海鲈鱼", "白切鸡", "蒸南瓜", "炒苦瓜", "蒸茄子", "清炒时蔬", "冬瓜排骨汤", "番茄牛腩煲", "虫草花炖瘦肉", "木耳炒山药", "蒸豆腐", "蒜泥白肉", "冬瓜瑶柱汤", "海带绿豆汤", "枸杞叶猪肝汤", "南瓜小米粥", "绿豆薏米汤", "红烧茄子", "蒜蓉粉丝蒸扇贝", "清炖羊肉", "鱼香茄子煲", "香菇滑鸡煲", "酸菜鱼", "宫保虾仁", "糖醋排骨", "香辣蟹", "干锅菜花", "手撕包菜", "凉拌海带丝", "凉拌莴苣", "凉拌西红柿", "凉拌莲藕", "凉拌豆皮","猪圈小米辣"
    };
    private Random random = new Random();

    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_food);

        mealGroup = findViewById(R.id.mealGroup);
        recommendationTextView = findViewById(R.id.recommendationTextView);

        findViewById(R.id.recommendButton).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 检查是否选择了餐点
                int selectedId = mealGroup.getCheckedRadioButtonId();
                if (selectedId == -1) {
                    recommendationTextView.setText("请选择餐点类型");
                    return;
                }

                // 获取选中的餐点
                RadioButton selectedMeal = findViewById(selectedId);
                String mealType = selectedMeal.getText().toString();

                // 根据选中的餐点显示推荐的食物
                String recommendation = getFoodRecommendation(mealType);
                recommendationTextView.setText(recommendation);
            }
        });
    }

    private String getFoodRecommendation(String mealType) {
        if ("早饭".equals(mealType)) {
            // 从早饭列表中随机选择一个食品
            int index = random.nextInt(breakfast.length);
            return "早饭推荐: " + breakfast[index];
        } else if ("午饭".equals(mealType)) {
            int index = random.nextInt(lunch.length);
            return "午饭推荐: " + lunch[index];

        } else if ("晚饭".equals(mealType)) {
            int index = random.nextInt(dinner.length);
            return "晚饭推荐: " + dinner[index];
        } else {
            return "请选择餐点类型";
        }
    }
}